﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title></title>
    <link href="../../static/css/font.css" rel="stylesheet" />
    <link href="../../static/css/weadmin.css" rel="stylesheet" />
    <link href="../../lib/layui/css/layui.css" rel="stylesheet" />
    <script src="../../../lib/layui/layui.js"></script>
    <style>.layui-tab-content {margin:0 auto;width: 90%;}</style>
</head>
<body>
    <div class="layui-form">
        <div class="layui-tab-content">
            <table id="dataList" lay-filter="dataList"></table>
        </div>
        </div>
    <script>
        layui.use(['form', 'laydate', 'table', 'jquery', 'element', 'layer', 'tree', 'util'], function () {
            var laydate = layui.laydate;
            var $ = layui.jquery
                , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
            th = $(document).height() * 0.5;
            tw = $(document).width();
            var table = layui.table;
            var form = layui.form;
            var element = layui.element;
            var layer = layui.layer;
            function formRenderSelect() {
                form.render('select');
            }
            var User_Id = "";
            var StartDateTime = "";
            var EndDateTime = "";
            if (GetQueryString("User_Id") != null) { User_Id = GetQueryString("User_Id"); }
            if (GetQueryString("startTime") != null) { StartDateTime = GetQueryString("startTime"); }
            if (GetQueryString("endTime") != null) { EndDateTime = GetQueryString("endTime"); }

            //车间数据开始
            function showList() {
                var swhere = JSON.stringify({
                    StartDateTime: StartDateTime,
                    EndDateTime: EndDateTime,
                    User_Id: User_Id
                });
                console.log(swhere);
                table.render({
                    elem: '#dataList'
                    , url: ApiUrl + 'TrainCourse/GetCourseCountContent'
                    , id: "dataList1"
                    , headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    }
                    , page: true
                    , cols: [[
                        { field: 'DepName', title: '培训内容'},
                        { field: 'x', title: '培训次数'}
                    ]]
                    , where: { swhere: swhere }
                    , parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                        if (res.data != null) {
                            var p = $(".layui-laypage-skip").find("input[type=text]").val();
                            var c = $(".layui-laypage-limits select").find("option:selected").text().substring(0, 2);
                            var k = (Number(p) - 1) * Number(c);
                            for (var i = 0; i < res.data.length; i++) {
                                var item = res.data[i];
                                var ix = item.Row - 1 - k;
                                $(".layui-table-body table tbody tr[data-index=" + ix + "]").attr("style", dataRowColor[item.TPDepLevel]);
                            }
                        }

                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
            }
            showList();
        });
    </script>

</body>
</html>